package com.pxst.init.bank;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.pxst.bank.entity.SysAvailableBankEntity;
import com.pxst.bank.service.SysAvailableBankService;
import com.pxst.enums.RedisKeyEnums;
import com.pxst.utils.RedisUtils;

import lombok.extern.slf4j.Slf4j;

/** 
 * 系统可用银行初始化成功
* @author yangxy
* @version 创建时间：2023年9月7日 下午4:37:13 
*/
@Slf4j
@Component
public class SysAvailableBankInit implements CommandLineRunner{
	@Autowired
	private RedisUtils redisUtils;
	@Autowired
	private SysAvailableBankService sysAvailableBankService;
	
	@Override
	public void run(String... args) throws Exception {
		// TODO Auto-generated method stub
		List<SysAvailableBankEntity> list = sysAvailableBankService.list(new LambdaQueryWrapper<SysAvailableBankEntity>().eq(SysAvailableBankEntity::getStatus, 1));
		if(!list.isEmpty()) {
			redisUtils.set(RedisKeyEnums.AVAILABLE_BANK.key, list);
		}
		log.info("系统可用银行初始化成功");
	}

}
